/*
 *
 * Copyright (C) 2012 Walter Lütgenau
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package offset.nodes.client.vdialog.model.instance;

import javax.jcr.RepositoryException;
import offset.nodes.Constants;

/**
 *
 * @author Walter Lütgenau
 */
public class VirtualPageInstance extends AbstractTemplateNodeInstance {

    public VirtualPageInstance() {
        super(Constants.TYPE_VIRTUAL_PAGE_INSTANCE);
    }

    public String getTemplateReference() throws RepositoryException {
        return getStringProperty(Constants.PROP_TEMPLATE_NODE_REFERENCE);
    }

    public void setTemplateReference(String templateReference) throws RepositoryException {
        setProperty(Constants.PROP_TEMPLATE_NODE_REFERENCE, templateReference);
    }

    public String[] getQueries() throws RepositoryException {
        return getStringArrayProperty(Constants.PROP_SECONDARY_QUERY);
    }

    public void setQueries(String[] queries) throws RepositoryException {
        setStringArrayProperty(Constants.PROP_SECONDARY_QUERY, queries);
    }

    public void setUseAsDefault(boolean value) throws RepositoryException {
        setBooleanProperty(Constants.PROP_DEFAULT_TEMPLATE, value);
    }

    public boolean isUseAsDefault() throws RepositoryException {
        Boolean value = getBooleanProperty(Constants.PROP_DEFAULT_TEMPLATE);
        if (value != null && value.booleanValue())
            return true;
        return false;
    }

}
